<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lesson 27</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="root"></div>
</body>

</html>
<script>
    // 状态动画
    const app = Vue.createApp({
        data() {
            return {
                number: 1,
                animateNumber: 1
            };
        },
        methods: {
            handleClick() {
                this.number = 10;
                let currentNumber = this.animateNumber;
                const animation = setInterval(() => {
                    currentNumber += 1;
                    this.animateNumber += 1;
                    if (currentNumber === 10) {
                        clearInterval(Animation);
                    }
                }, 100)
            },
        },
        template: `
        <div>
            <div>{{animateNumber}}</div>
            <button @click="handleClick">增加</button>
        </div>
        `
    });

    const vm = app.mount("#root")
</script>